//
//  HRZStoreMainHeadCell.m
//  EMarket
//
//  Created by 物联速通信息技术有限公司 on 2018/5/24.
//  Copyright © 2018 好日子. All rights reserved.
//

#import "HRZStoreMainHeadCell.h"

// Controllers

// Models
#import "HRZStoreModel.h"
// Views

// Vendors
#import <UIImageView+WebCache.h>
// Categories
#import "UIView+SPExtension.h"
// Others
#import "HRZSpeedy.h"

@interface HRZStoreMainHeadCell ()

@property (weak, nonatomic) IBOutlet UIImageView *storeLogoImageView;
@property (weak, nonatomic) IBOutlet UILabel *storeNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *storeGoodsCountLabel;
@property (weak, nonatomic) IBOutlet UIButton *followStoreButton;

@end

@implementation HRZStoreMainHeadCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [HRZSpeedy hrz_setUpBezierPathCircularLayerWithControl:_followStoreButton size:_followStoreButton.sp_size];
    
    _followStoreButton.layer.borderWidth = .5f;
    _followStoreButton.layer.borderColor = HRZThemeColor.CGColor;
    [_followStoreButton setTitleColor:HRZThemeColor forState:UIControlStateNormal];
    
    
    _storeLogoImageView.layer.borderWidth = .5f;
    _storeLogoImageView.layer.borderColor = HRZBGColor.CGColor;
    
    _storeNameLabel.textColor = HRZThemeColor;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)onFollowButtonClick:(id)sender {
    !_FollowBlock ?: _FollowBlock(!_storeModel.isUserFollow);
}

- (void)setStoreModel:(HRZStoreModel *)storeModel {
    _storeModel = storeModel;
    
    [_storeLogoImageView sd_setImageWithURL:URLString(storeModel.storeLogoURL) placeholderImage:PLACEHOLDERIMAGE];
    
    _storeNameLabel.text = _storeModel.storeName;
    
    _storeGoodsCountLabel.text = [NSString stringWithFormat:@"%d",(int)_storeModel.storeSellGoodsCount];
    
    [self setfollowButtonWithIsFollowing:storeModel.isUserFollow];
}


- (void)setfollowButtonWithIsFollowing:(BOOL)is {
    if (is) {
        [_followStoreButton setTitle:@"已关注" forState:UIControlStateNormal];
    } else {
        [_followStoreButton setTitle:@"关注" forState:UIControlStateNormal];
    }
}


@end
